package org.jeecg.modules.CheckTask.service.impl;


import com.mchange.v2.uid.UidUtils;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.utils.UuidUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.CheckTask.entity.CheckTaskDetail;
import org.jeecg.modules.CheckTask.mapper.CheckTaskDetailMapper;
import org.jeecg.modules.CheckTask.service.ICheckTaskDetailService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 排查任务明细表
 * @Author: jeecg-boot
 * @Date:   2023-02-21
 * @Version: V1.0
 */
@Service
@Slf4j
public class CheckTaskDetailServiceImpl extends ServiceImpl<CheckTaskDetailMapper, CheckTaskDetail> implements ICheckTaskDetailService {
	
	@Autowired
	private CheckTaskDetailMapper checkTaskDetailMapper;
	
	@Override
	public List<CheckTaskDetail> selectByMainId(String mainId) {
		return checkTaskDetailMapper.selectByMainId(mainId);
	}

	@Override
	public Result<String> appSubmitTaskDetail(CheckTaskDetail checkTaskDetail) {
		checkTaskDetail.setId(UuidUtils.getUUID());
		checkTaskDetail.setCreateTime(new Date());
		checkTaskDetail.setUpdateTime(new Date());
		checkTaskDetail.setCreateBy("sys");
		checkTaskDetail.setRectiftState("0");
		checkTaskDetail.setReportDate(new Date());
		checkTaskDetailMapper.insert(checkTaskDetail);
		return Result.OK("操作成功！");
	}

	@Override
	public Result<List<CheckTaskDetail>> appGetCheckTaskDetail(CheckTaskDetail checkTaskDetail) {
		List<CheckTaskDetail> checkTaskDetails = checkTaskDetailMapper.appGetCheckTaskDetail(checkTaskDetail.getId(), checkTaskDetail.getRegionName(), checkTaskDetail.getRectiftState());
		return Result.OK(checkTaskDetails);
	}
}
